home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-glow-arrow.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  5.7 KB  |  164 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Alien Glow themed arrows for web pages
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ;
  8. ; Based on code from
  9. ; Federico Mena Quintero
  10. ; federico@nuclecu.unam.mx
  11. ; This program is free software; you can redistribute it and/or modify
  12. ; it under the terms of the GNU General Public License as published by
  13. ; the Free Software Foundation; either version 2 of the License, or
  14. ; (at your option) any later version.
  15. ; This program is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ; GNU General Public License for more details.
  19. ; You should have received a copy of the GNU General Public License
  20. ; along with this program; if not, write to the Free Software
  21. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. (define (script-fu-alien-glow-right-arrow size
  24.                                           orientation
  25.                                           glow-color
  26.                                           bg-color
  27.                                           flatten)
  28.  
  29.   ; some local helper functions, better to not define globally,
  30.   ; since otherwise the definitions could be clobbered by other scripts.
  31.   (define (map proc seq)
  32.     (if (null? seq)
  33.         '()
  34.         (cons (proc (car seq))
  35.               (map proc (cdr seq)))))
  36.  
  37.   (define (for-each proc seq)
  38.     (if (not (null? seq))
  39.         (begin
  40.           (proc (car seq))
  41.           (for-each proc (cdr seq)))))
  42.  
  43.   (define (make-point x y)
  44.     (cons x y))
  45.  
  46.   (define (point-x p)
  47.     (car p))
  48.  
  49.   (define (point-y p)
  50.     (cdr p))
  51.  
  52.   (define (point-list->double-array point-list)
  53.     (define (convert points array pos)
  54.       (if (not (null? points))
  55.           (begin
  56.             (aset array (* 2 pos) (point-x (car points)))
  57.             (aset array (+ 1 (* 2 pos)) (point-y (car points)))
  58.             (convert (cdr points) array (+ pos 1)))))
  59.  
  60.     (let* ((how-many (length point-list))
  61.            (a (cons-array (* 2 how-many) 'double)))
  62.       (convert point-list a 0)
  63.       a))
  64.  
  65.   (define (make-arrow size
  66.                       offset)
  67.     (list (make-point offset offset)
  68.           (make-point (- size offset) (/ size 2))
  69.           (make-point offset (- size offset))))
  70.  
  71.  
  72.   (define (rotate-points points size orientation)
  73.     (map (lambda (p)
  74.            (let ((px (point-x p))
  75.                  (py (point-y p)))
  76.              (cond ((= orientation 0) (make-point px py))           ; right
  77.                    ((= orientation 1) (make-point (- size px) py))  ; left
  78.                    ((= orientation 2) (make-point py (- size px)))  ; up
  79.                    ((= orientation 3) (make-point py px)))))        ; down
  80.          points))
  81.  
  82.  
  83.   ; the main function
  84.  
  85.   (let* ((img (car (gimp-image-new size size RGB)))
  86.          (grow-amount (/ size 12))
  87.          (blur-radius (/ size 3))
  88.          (offset (/ size 6))
  89.          (ruler-layer (car (gimp-layer-new img
  90.                                            size size RGBA-IMAGE
  91.                                            "Ruler" 100 NORMAL-MODE)))
  92.          (glow-layer (car (gimp-layer-new img
  93.                                           size size RGBA-IMAGE
  94.                                           "Alien Glow" 100 NORMAL-MODE)))
  95.          (bg-layer (car (gimp-layer-new img
  96.                                         size size RGB-IMAGE
  97.                                         "Background" 100 NORMAL-MODE)))
  98.          (big-arrow (point-list->double-array
  99.                      (rotate-points (make-arrow size offset)
  100.                                      size orientation))))
  101.  
  102.     (gimp-context-push)
  103.  
  104.     (gimp-image-undo-disable img)
  105.     ;(gimp-image-resize img (+ length height) (+ height height) 0 0)
  106.     (gimp-image-add-layer img bg-layer 1)
  107.     (gimp-image-add-layer img glow-layer -1)
  108.     (gimp-image-add-layer img ruler-layer -1)
  109.     
  110.     (gimp-edit-clear glow-layer)
  111.     (gimp-edit-clear ruler-layer)
  112.  
  113.     (gimp-free-select img 6 big-arrow CHANNEL-OP-REPLACE TRUE FALSE 0)
  114.  
  115.     (gimp-context-set-foreground '(103 103 103))
  116.     (gimp-context-set-background '(0 0 0))
  117.  
  118.     (gimp-edit-blend ruler-layer FG-BG-RGB-MODE NORMAL-MODE
  119.                      GRADIENT-SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE
  120.                      FALSE 0 0 TRUE
  121.                      0 0 size size)
  122.     
  123.     (gimp-selection-grow img grow-amount)
  124.     (gimp-context-set-foreground glow-color)
  125.     (gimp-edit-fill glow-layer FOREGROUND-FILL)
  126.  
  127.     (gimp-selection-none img)
  128.  
  129.  
  130.     (plug-in-gauss-rle 1 img glow-layer blur-radius TRUE TRUE)
  131.  
  132.     (gimp-context-set-background bg-color)
  133.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  134.  
  135.     (if (= flatten TRUE)
  136.         (gimp-image-flatten img))
  137.     (gimp-image-undo-enable img)
  138.     (gimp-display-new img)
  139.  
  140.     (gimp-context-pop)))
  141.  
  142. (script-fu-register "script-fu-alien-glow-right-arrow"
  143.                     _"_Arrow..."
  144.                     "Create an X-file deal"
  145.                     "Adrian Likins"
  146.                     "Adrian Likins"
  147.                     "1997"
  148.                     ""
  149.                     SF-ADJUSTMENT _"Size"            '(32 5 150 1 10 0 1)
  150.                     SF-OPTION     _"Orientation"     '(_"Right" 
  151.                                                        _"Left" 
  152.                                                        _"Up" 
  153.                                                        _"Down")
  154.                     SF-COLOR      _"Glow color"       '(63 252 0)
  155.                     SF-COLOR      _"Background color" '(0 0 0)
  156.                     SF-TOGGLE     _"Flatten image"    TRUE)
  157.  
  158. (script-fu-menu-register "script-fu-alien-glow-right-arrow"
  159.              _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Alien Glow")
  160.